/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.team1160.breakaway.ballControl;

import com.team1160.breakaway.api.Constants;
import com.team1160.breakaway.model.Model;
import com.team1160.breakaway.model.ModelNotifier;
import com.team1160.breakaway.util.Piston;

/**
 *
 * @author Team 1160 Firebird Robotics (saketh kasibatla)
 */
public class Kicker implements ModelNotifier
{
    protected Piston fire=new Piston(Constants.C_FIRE_FRONT,Constants.C_FIRE_BACK);
    protected Piston latch = new Piston(Constants.C_LATCH_FRONT,Constants.C_LATCH_BACK);
    protected boolean fireFront=false, fireBack=false;
    protected boolean latchFront=false, latchBack=false;


    public Kicker()
    {
        
        this.fire.retract();
        this.latch.retract();
    }

    public void updateModel(Model model)
    {
        updateSolenoids(model);
    }

    protected void updateSolenoids(Model model){
        if(fire.isExtended()){
            fireBack=true;
            fireFront=false;
        } else {
            fireBack=false;
            fireFront=true;
        }

        if(latch.isExtended()){
            latchBack=true;
            latchFront=false;
        } else {
            latchBack=false;
            latchFront=true;
        }

        model.setSolenoidValue(Constants.ID_KICKER_SOLENOID_FIRE_BACK, fireBack);
        model.setSolenoidValue(Constants.ID_KICKER_SOLENOID_FIRE_FRONT, fireFront);
        model.setSolenoidValue(Constants.ID_KICKER_SOLENOID_LATCH_BACK, latchBack);
        model.setSolenoidValue(Constants.ID_KICKER_SOLENOID_LATCH_FRONT, latchFront);
        
    }

    public void extendFire(){
        this.fire.fire();
    }

    public void retractFire(){
        this.fire.retract();
    }

    public void extendLatch(){
        this.latch.fire();
    }

    public void retractLatch(){
        this.latch.retract();
    }
    
}
